/// <reference path="../../Resources/js/jquery/jquery.debug.js" />

Type.registerNamespace("BM");

// CheckBoxValueHandler object

BM.CheckBoxValueHandler = function(leafItem) {
    BM.CheckBoxValueHandler.initializeBase(this, [leafItem]);
}

BM.CheckBoxValueHandler.prototype = {    
    
    getInputsPath: function() {
        return " > input[type = checkbox]";
    },
            
    getOffValue: function() {  
        /// <returns type="String" >
        /// the returning value of the leaf, if checkbox is not checked
        /// </returns>      
        return this.getInputsContainer().getAttribute("offValue");
    },
    
    getOnValue: function() {        
        /// <returns type="String" >
        /// the returning value of the leaf, if checkbox is checked
        /// </returns>      
        return this.getInputsContainer().getAttribute("onValue");
    },
    
    getControlValue: function() {
        var input = this.getInput();
        if (input.checked) return this.getOnValue(); 
        return this.getOffValue();            
    },

    setControlValue: function(value) {
        var input = this.getInput();
        if (input.value == value) input.checked = true;
        else input.checked = false;
    }      
}

BM.ValueHandler['CheckBoxValueHandler'] = BM.CheckBoxValueHandler;
BM.CheckBoxValueHandler.registerClass("BM.CheckBoxValueHandler", BM.InputsContainerValueHandler);